#include <thread>
#include <unistd.h>
#include <iostream>

void task(int n, std::thread* th)
{
   while (n--)
   {
      std::cout << "i am a thread, id:" <<std::this_thread::get_id() <<
	  ", n:" << n << std::endl;
      sleep(1);
   }
   std::cout << "task done, id: " << th->get_id() << std::endl;
}

int main()
{
   std::thread th(task, 5, &th);
   th.join();
   // std::cout << "thread quit, id: " << th.get_id() << std::endl;
   return 0;
}
